<?php

class Uuch_Track_KuaiDiAPI{
    public $type;
    public $postid;
    public function __construct($type,$postid) {
        $this->type = $type;
        $this->postid = $postid;
    }
    
    public function query(){
        $html = file_get_contents("http://www.kuaidi100.com/query?type=$this->type&postid=$this->postid");
        $res = json_decode($html);
        if($res->message == "ok"){
            $table = "<table><tr><td>Date and Time</td><td>Content</td></tr>";
            $tr = "";
            foreach($res->data as $val){            
                $tr.="<tr><td>".$val->time."</td><td>".$val->context."</td></tr>";
            }
            return $table.$tr."</table>";
        }else{
            return false;
        }
    }
    
}










?>
